//
//  XMLVisitorMessageModel.m
//  ppkc2016
//
//  Created by 拼凑的断音 on 16/4/13.
//  Copyright © 2016年 拼凑的断音. All rights reserved.
//

#import "XMLVisitorMessageModel.h"
#import "XXTool.h"

@implementation XMLVisitorMessageModel

+(void)requestVisitorMessageWithAcceptType:(NSString *)accept listCount:(NSInteger)count completion:(void (^)(BOOL, NSMutableArray<XMLVisitorMessageModel *> *))block
{
    [DKHTTPRequest sendNewDataWithShortUrl:@"msg_usr_info_list_2017_"
                                  Param:[XXTool formatStringWithLanguage:[NSString stringWithFormat:@"userid=%@&passwd=%@&nstart=%ld&ntotal=10&accept=%@",[UserInfo shareUserInfo].userID,[UserInfo shareUserInfo].userPassword,count,accept]]
                             ImageArray:nil
                                TimeOut:10
                             Completion:^BOOL(NSMutableDictionary *serverDic, DKHTTPResponseType bufferType) {
                                 if ([[serverDic objectForKey:@"code"] intValue]==200)
                                 {
                                     NSMutableArray *datalist = [NSMutableArray array];
                                     if ([[serverDic objectForKey:@"total"] intValue]!=0)
                                     {
                                         NSArray *tempArray = [serverDic objectForKey:@"list"];
                                         for (NSDictionary* temp in tempArray)
                                         {
                                             [datalist addObject:[XMLVisitorMessageModel modelWithDictionary:temp]];
                                         }
                                     }
                                     block(YES,datalist);
                                 }
                                 else
                                 {
                                   
                                     block(NO,nil);
                                 }
                                 return YES;
                             } IsBuffering:YES
                      IsNeedReplaceWrap:NO
                        IsUseUpLoadHead:NO];
}

+(void)requestVisitorLiuyanMessageWithType:(NSInteger)count completion:(void (^)(BOOL, NSMutableArray<XMLVisitorMessageModel *> *))block{
    [DKHTTPRequest sendNewDataWithShortUrl:@"messageboard_usr_info_list_2017_"
                                     Param:[XXTool formatStringWithLanguage:[NSString stringWithFormat:@"userid=%@&passwd=%@&nstart=%ld&ntotal=10&",[UserInfo shareUserInfo].userID,[UserInfo shareUserInfo].userPassword,count]]
                                ImageArray:nil
                                   TimeOut:10
                                Completion:^BOOL(NSMutableDictionary *serverDic, DKHTTPResponseType bufferType) {
                                    if ([[serverDic objectForKey:@"code"] intValue]==200)
                                    {
                                        NSMutableArray *datalist = [NSMutableArray array];
                                        
                                            NSArray *tempArray = [serverDic objectForKey:@"list"];
                                            for (NSDictionary* temp in tempArray)
                                            {
                                                [datalist addObject:[XMLVisitorMessageModel modelWithDictionary:temp]];
                                            }
                                        block(YES,datalist);
                                    }
                                    else
                                    {
                                        
                                        block(NO,nil);
                                    }
                                    return YES;
                                } IsBuffering:YES
                         IsNeedReplaceWrap:NO
                           IsUseUpLoadHead:NO];
}

/**
 * 留言
 */
+(void)requestVisitorSendLiuyanType:(NSString *)content orderId:(NSString*)id
                                Url:(NSString*) url completion:(void (^)(BOOL))block{
    [DKHTTPRequest sendNewDataWithShortUrl:url
                                     Param:[XXTool formatStringWithLanguage:[NSString stringWithFormat:@"userid=%@&passwd=%@&orderid=%@&content=%@&",[UserInfo shareUserInfo].userID,[UserInfo shareUserInfo].userPassword,id,content]]
                                ImageArray:nil
                                   TimeOut:10
                                Completion:^BOOL(NSMutableDictionary *serverDic, DKHTTPResponseType bufferType) {
                                    if ([[serverDic objectForKey:@"code"] intValue]==200)
                                    {
                                        block(YES);
                                    }
                                    else
                                    {
                                        
                                        block(NO);
                                    }
                                    return YES;
                                } IsBuffering:YES
                         IsNeedReplaceWrap:NO
                           IsUseUpLoadHead:NO];
}

@end
